Skip to content

Comments

swev-id: pytest-dev__pytest-7432 fix: preserve skip item location under --runxfail#34

Open
casey-brooks wants to merge 2 commits intopytest-dev__pytest-7432from
fix/runxfail-skip-location-7432
Open

swev-id: pytest-dev__pytest-7432 fix: preserve skip item location under --runxfail#34
casey-brooks wants to merge 2 commits intopytest-dev__pytest-7432from
fix/runxfail-skip-location-7432

Conversation

@casey-brooks
Copy link

Summary

  • guard xfail-only report branches when --runxfail is active so the skip-location rewrite still executes
  • remove the early --runxfail bypass to keep skip reports tied to their test definitions

Fixes #29.

Observed failure (pre-fix)

Commands were run from /workspace/tmp_skip_tests with the repo venv activated (PYTEST_DISABLE_PLUGIN_AUTOLOAD=1).

PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/pytest -q -rs test_skip.py --runxfail
s                                                                        [100%]
=========================== short test summary info ============================
SKIPPED [1] ../pytest/src/_pytest/skipping.py:239: skip me
1 skipped in 0.00s
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/pytest -q -rs test_skipif.py --runxfail
s                                                                        [100%]
=========================== short test summary info ============================
SKIPPED [1] ../pytest/src/_pytest/skipping.py:239: conditional skip
1 skipped in 0.00s

Verification

PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/pytest -q -rs test_skip.py --runxfail
s                                                                        [100%]
=========================== short test summary info ============================
SKIPPED [1] test_skip.py:4: skip me
1 skipped in 0.00s
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/pytest -q -rs test_skipif.py --runxfail
s                                                                        [100%]
=========================== short test summary info ============================
SKIPPED [1] test_skipif.py:4: conditional skip
1 skipped in 0.00s
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/pytest -q -rs test_xfail.py
x                                                                        [100%]
1 xfailed in 0.01s
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/pytest -q -rs test_xfail.py --runxfail
F                                                                        [100%]
=================================== FAILURES ===================================
_______________________________ test_xfail_fails _______________________________

    @pytest.mark.xfail(reason="expected failure")
    def test_xfail_fails():
>       assert False
E       assert False

test_xfail.py:6: AssertionError
1 failed in 0.01s

Notes

  • Direct pytest.skip calls continue to respect the original call site.
  • unittest-style tests still report unexpected successes/failures exactly as before.
  • CI intentionally not triggered per repository policy.

@casey-brooks casey-brooks requested a review from a team December 25, 2025 21:11
@casey-brooks
Copy link
Author

Test & Lint Summary

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/pytest -q -rs test_skip.py → 1 skipped
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/pytest -q -rs test_skip.py --runxfail → 1 skipped
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/pytest -q -rs test_skipif.py → 1 skipped
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/pytest -q -rs test_skipif.py --runxfail → 1 skipped
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/pytest -q -rs test_xfail.py → 1 xfailed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/pytest -q -rs test_xfail.py --runxfail → 1 failure (expected under --runxfail)
  • git diff -- src/_pytest/skipping.py | flake8 --diff → no lint findings

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks correct, but we need a regression test so this behavior stays covered. Please add coverage for the skip-location rewrite when running with --runxfail.

@casey-brooks
Copy link
Author

Added regression coverage:

  • .. [100%]
    2 passed in 0.03s → 2 passed

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regression coverage looks good—thanks for adding the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants